
// panel object
local PANEL = {};


/*------------------------------------
	initialize the seek bar
------------------------------------*/
function PANEL:Init( )

	// lock the vertical movement in the middle
	self:SetLockY( 0.5 );
	
	// trap cursor
	self:SetTrapInside( true );
	
	// set the default image
	self:SetImage( "vgui/slider" );
	
	// hook for skins to change
	MuseX.SkinHook( "SliderKnob", self, "SetImage" );
	
	// custom paint hook
	Derma_Hook( self, "Paint", "Paint", "MXSlider" );

end


/*------------------------------------
	seek bar thinking
------------------------------------*/
function PANEL:Think( )

	// check if we're being dragged
	if ( self.Dragging ) then
	
		// don't think, be stupid, eat drugs, smoke food
		return;
		
	end

	// check if a song is playing or paused
	if ( !MuseX.IsPlaying() && !MuseX.IsPaused() ) then
	
		// lock the position at beginning
		self:SetPosition( 0 );
	
	end

end


/* CUSTOM PANEL FUNCTIONS */


/*------------------------------------
	set the position of the slider
------------------------------------*/
function PANEL:SetPosition( frac )

	// move the slider to match position
	self:SetSlideX( frac );
		
end

// define
derma.DefineControl( "MXSeekBar", "", PANEL, "DSlider" );
